Diff for /loncom/interface/lonnavmaps.pm between versions 1.269 and 1.270

version 1.269, 2004/07/21 20:19:01 version 1.270, 2004/07/23 22:38:10
Line 100  sub launch_win { Line 100  sub launch_win {
     }      }
     if ($mode eq 'link') {      if ($mode eq 'link') {
  $result.='<a href="javascript:launch_navmapwin();void(0);">'   $result.='<a href="javascript:launch_navmapwin();void(0);">'
     .&mt("Launch Navmaps in seperate window")."</a>";      .&mt("Launch Navmaps in seperate window")."</a> ";
     }      }
     return $result;      return $result;
 }  }
Line 119  window.status='Done.'; Line 119  window.status='Done.';
 ENDCLOSE  ENDCLOSE
 }  }
   
   sub update {
       if ($ENV{'environment.remotenavmap'} ne 'on') { return ''; }
       if (!$ENV{'request.course.id'}) { return ''; }
       if ($ENV{'REQUEST_URI'}=~m|^/adm/navmaps|) { return ''; }
       return(<<ENDUPDATE);
   <form name="navform"></form>
   <script type="text/javascript">
   this.document.navform.action='/adm/navmaps#curloc';
   this.document.navform.target='loncapanav';
   this.document.navform.submit();
   </script>
   ENDUPDATE
   }
   
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
Line 182  ENDSUBM Line 195  ENDSUBM
     $r->print("<html><head>\n");      $r->print("<html><head>\n");
     $r->print("<title>".&mt('Navigate Course Contents')."</title>");      $r->print("<title>".&mt('Navigate Course Contents')."</title>");
 # ------------------------------------------------------------ Get query string  # ------------------------------------------------------------ Get query string
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register']);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register','sort']);
           
 # ----------------------------------------------------- Force menu registration  # ----------------------------------------------------- Force menu registration
     my $addentries='';      my $addentries='';
Line 326  ENDSUBM Line 339  ENDSUBM
        &mt("Show Only Uncompleted Homework")."</a>&nbsp;&nbsp;&nbsp;&nbsp;");         &mt("Show Only Uncompleted Homework")."</a>&nbsp;&nbsp;&nbsp;&nbsp;");
     }      }
   
       $r->print("<form>
                    <nobr>
                       Sort by:
                       <select name=\"sort\">
                          <option value=\"\"></option>
                          <option value=\"title\">Title</option>
                          <option value=\"duedate\">Duedate</option>
                       </select>
                       <input type=\"submit\" name=\"Sort\" />
                    </nobr>
                  </form>");
     # renderer call      # renderer call
     my $renderArgs = { 'cols' => [0,1,2,3],      my $renderArgs = { 'cols' => [0,2,3],
          'sort' => $ENV{'form.sort'},
                        'url' => '/adm/navmaps',                         'url' => '/adm/navmaps',
                        'navmap' => $navmap,                         'navmap' => $navmap,
                        'suppressNavmap' => 1,                         'suppressNavmap' => 1,
Line 1347  sub render { Line 1372  sub render {
             #$currenturl=~s/^[^\/]+//;              #$currenturl=~s/^[^\/]+//;
                           
             $here = $jump = &Apache::lonnet::symbread($currenturl);              $here = $jump = &Apache::lonnet::symbread($currenturl);
         }          } else {
       &Apache::lonnet::logthis("Hrrm,");
       
    }
   
         # Step three: Ensure the folders are open          # Step three: Ensure the folders are open
         my $mapIterator = $navmap->getIterator(undef, undef, undef, 1);          my $mapIterator = $navmap->getIterator(undef, undef, undef, 1);
Line 1574  END Line 1602  END
     $args->{'here'} = $here;      $args->{'here'} = $here;
   
     $args->{'indentLevel'} = -1; # first BEGIN_MAP takes this to 0      $args->{'indentLevel'} = -1; # first BEGIN_MAP takes this to 0
     while ($curRes = $it->next($closeAllPages)) {      my @resources;
       my $code='';# sub { !(shift->is_map();) };
       if ($args->{'sort'} eq 'title') {
    @resources=$navmap->retrieveResources(undef,
          sub { !shift->is_map(); });
    @resources= sort {lc($a->compTitle) cmp lc($b->compTitle)} @resources;
       } elsif ($args->{'sort'} eq 'duedate') {
    @resources=$navmap->retrieveResources(undef,
          sub { shift->is_problem(); });
    @resources= sort
    {
       if ($a->duedate ne $b->duedate) {
           return $a->duedate cmp $b->duedate;
       } else {
    lc($a->compTitle) cmp lc($b->compTitle)
       }
    } @resources;
       }
   
       while (1) {
    if ($args->{'sort'}) {
       $curRes = shift(@resources);
    } else {
       $curRes = $it->next($closeAllPages);
    }
    if (!$curRes) { last; }
   
         # Maintain indentation level.          # Maintain indentation level.
         if ($curRes == $it->BEGIN_MAP() ||          if ($curRes == $it->BEGIN_MAP() ||
             $curRes == $it->BEGIN_BRANCH() ) {              $curRes == $it->BEGIN_BRANCH() ) {
Line 1688  END Line 1742  END
   
             # Set up some data about the parts that the cols might want              # Set up some data about the parts that the cols might want
             my $filter = $it->{FILTER};              my $filter = $it->{FILTER};
             my $stack = $it->getStack();      my $src;
             my $src = getLinkForResource($stack);      if ($args->{'sort'}) {
    $src = $curRes->src(); # FIXME this is wrong for .pages
       } else {
    my $stack = $it->getStack();
    $src=getLinkForResource($stack);
       }
             my $anchor='';              my $anchor='';
             if ($src=~s/(\#.*$)//) {              if ($src=~s/(\#.*)$//) {
  $anchor=$1;   $anchor=$1;
     }      }
             my $srcHasQuestion = $src =~ /\?/;              my $srcHasQuestion = $src =~ /\?/;
Line 1699  END Line 1758  END
                 ($srcHasQuestion?'&':'?') .                  ($srcHasQuestion?'&':'?') .
                 'symb=' . &Apache::lonnet::escape($curRes->symb()).                  'symb=' . &Apache::lonnet::escape($curRes->symb()).
  $anchor;   $anchor;
               
             # Now, display each column.              # Now, display each column.
             foreach my $col (@$cols) {              foreach my $col (@$cols) {
                 my $colHTML = '';                  my $colHTML = '';

Removed from v.1.269  
changed lines
  Added in v.1.270


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