Diff for /rat/lonsequence.pm between versions 1.17 and 1.23

version 1.17, 2004/05/21 20:16:40 version 1.23, 2005/03/01 00:22:57
Line 28 Line 28
 #  #
 # (Handler to resolve ambiguous file locations  # (Handler to resolve ambiguous file locations
 #  #
 # (TeX Content Handler  
 #  
 # 05/29/00,05/30,10/11 Gerd Kortemeyer)  
 #  
 # 10/11,10/12 Gerd Kortemeyer)  
 #  
 # 10/16 Gerd Kortemeyer  
   
 package Apache::lonsequence;  package Apache::lonsequence;
   
Line 246  sub handler { Line 239  sub handler {
 # ------------------------------------------------------------ Tie symb db file  # ------------------------------------------------------------ Tie symb db file
   my $disurl='';    my $disurl='';
   my $dismapid='';    my $dismapid='';
     my $exitdisid = '';
     my $arrow_dir = '';
   
   if (($ENV{'request.course.fn'}) && (!$ENV{'form.forceselect'})) {    if (($ENV{'request.course.fn'}) && (!$ENV{'form.forceselect'})) {
        my $last;         my $last;
Line 257  sub handler { Line 252  sub handler {
        my $direction='';         my $direction='';
        my $prevmap='';         my $prevmap='';
        if ($last) {         if ($last) {
   ($prevmap,$direction)=(split(/\_\_\_/,$last));     ($prevmap,undef,$direction)=&Apache::lonnet::decode_symb($last);
        }         }
 # ------------------------------------------------------------- Tie big db file  # ------------------------------------------------------------- Tie big db file
        if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',         if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
Line 269  sub handler { Line 264  sub handler {
        $disid=$bighash{'map_finish_'.$requrl};         $disid=$bighash{'map_finish_'.$requrl};
            } else {             } else {
                $disid=$bighash{'map_start_'.$requrl};                 $disid=$bighash{'map_start_'.$requrl};
            }              }
            if ($disid) {             if ($disid) {
        $disurl=$bighash{'src_'.$disid};         $disurl=$bighash{'src_'.$disid};
                $dismapid=(split(/\./,$disid))[1];                 $dismapid=(split(/\./,$disid))[1];
                $randomout = $bighash{'randomout_'.$disid};                 $randomout = $bighash{'randomout_'.$disid};
              } elsif (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db',
                       &GDBM_READER(),0640)) {
                  $last=$hash{'last_known'};
                  untie(%hash);
            }             }
   
   
 # ----------- If this is an empty one, or hidden, skip to next non-empty or non-hidden one  # ----------- If this is an empty one, or hidden, skip to next non-empty or non-hidden one
            if ( ((!$disurl) && ($disid)) || ($randomout && $disid) ) {             while ( ((!$disurl) && ($disid)) || ($randomout && $disid) ) {
        $direction=($direction?$direction:'forward');         $direction=($direction?$direction:'forward');
                ($disid,$requrl)=                 ($disid,$requrl)=
                          &Apache::lonpageflip::fullmove($disid,                           &Apache::lonpageflip::fullmove($disid,
Line 284  sub handler { Line 285  sub handler {
                if ($disid) {                 if ($disid) {
            $disurl=$bighash{'src_'.$disid};             $disurl=$bighash{'src_'.$disid};
                    $dismapid=(split(/\./,$disid))[1];                     $dismapid=(split(/\./,$disid))[1];
                      $randomout = $bighash{'randomout_'.$disid};
                }                 }
     }      }
              $exitdisid = $disid;
              $arrow_dir = $direction;
   
 # --------------------------------------- Untie hash, make sure to come by here  # --------------------------------------- Untie hash, make sure to come by here
            untie(%bighash);             untie(%bighash);
Line 293  sub handler { Line 297  sub handler {
    }     }
   
 # now either disurl is set (going to first page), or we need another display  # now either disurl is set (going to first page), or we need another display
   
    if ($disurl) {     if ($disurl) {
 # -------------------------------------------------- Has first or last resource  # -------------------------------------------------- Has first or last resource
       &Apache::lonnet::symblist($requrl,$disurl => $dismapid,        &Apache::lonnet::symblist($requrl,$disurl => [$disurl,$dismapid],
                    'last_known' => &Apache::lonnet::declutter($disurl));    'last_known' => [$disurl,$dismapid]); 
       &Apache::loncommon::content_type($r,'text/html');        &Apache::loncommon::content_type($r,'text/html');
       $r->header_out(Location => 'http://'.$ENV{'HTTP_HOST'}.$disurl);        $r->header_out(Location => 'http://'.$ENV{'HTTP_HOST'}.$disurl);
       return REDIRECT;        return REDIRECT;
    } else {     } else {
        &Apache::loncommon::content_type($r,'text/html');         &Apache::loncommon::content_type($r,'text/html');
        $r->send_http_header;         $r->send_http_header;
        &viewmap($r,$requrl);         if ($exitdisid eq '' && $arrow_dir ne '') {
              my %lt =&Apache::lonlocal::texthash(
                      'back' => 'beginning',
                      'forward' => 'end',
                      'emfo' => 'Empty Folder/Sequence',
                      'nere' => 'Next resource could not be displayed',
                      'goba' => 'Go Back',
                      'nacc' => 'Navigate Course Content',
                             );
              my $warnmsg = 'As all folders and sequences ';
              if ($arrow_dir eq 'forward') {
                  $warnmsg .= &mt('following the current resource were empty').',';
              } elsif ($arrow_dir eq 'back') {
                  $warnmsg .= &mt('preceding the current resource were empty').',';
              }
              $warnmsg .= &mt('you have now reached the').' '.$lt{$arrow_dir}.' '.&mt('of the course.');
              my $bodytag=&Apache::loncommon::bodytag('Empty Folder/Sequence');
              $r->print(<<ENDNONE);
   <head><title>$lt{'emfo'}</title></head>
   $bodytag
   <h3>$lt{'nere'}</h3>
   <p>$warnmsg</p>
   <ul>
     <li><a href="javascript:history.go(-1)">$lt{'goba'}</a></li>
     <li><a href="/adm/navmaps">$lt{'nacc'}</a></li>
   </ul>
   </body>
    </html>
   ENDNONE
          } else {
              &viewmap($r,$requrl);
          }
        return OK;         return OK;
    }     }
 }  }

Removed from v.1.17  
changed lines
  Added in v.1.23


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