Diff for /loncom/interface/lonnavmaps.pm between versions 1.275 and 1.280

version 1.275, 2004/08/13 20:12:11 version 1.280, 2004/08/27 20:34:13
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 navigation in separate window")."</a> ";      .&mt("Launch navigation window")."</a>&nbsp;&nbsp;&nbsp;&nbsp;";
     }      }
     return $result;      return $result;
 }  }
Line 119  window.status='Done.'; Line 119  window.status='Done.';
 ENDCLOSE  ENDCLOSE
 }  }
   
   sub nav_control_js {
       my $nav=($ENV{'environment.remotenavmap'} eq 'on');
       return (<<NAVCONTROL);
       var w_loncapanav_flag="$nav";
   
   
   function gonav(url) {
      if (w_loncapanav_flag != 1) {
         go(url);
      }  else {
         navwindow=window.open(url,
                     "loncapanav","height=600,width=400,scrollbars=1"); 
      }
   }
   NAVCONTROL
   }
   
 sub update {  sub update {
     if ($ENV{'environment.remotenavmap'} ne 'on') { return ''; }      if ($ENV{'environment.remotenavmap'} ne 'on') { return ''; }
     if (!$ENV{'request.course.id'}) { return ''; }      if (!$ENV{'request.course.id'}) { return ''; }
Line 172  sub real_handler { Line 189  sub real_handler {
              swmenu.clearTimeout(swmenu.menucltim);               swmenu.clearTimeout(swmenu.menucltim);
      $navstatus       $navstatus
 MENU  MENU
           } else {
       my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
       my $mainwindow='window.open('.$nothing.',"loncapaclient","",false);';
       $menu=(<<MENU)
                swmenu=$mainwindow
        $navstatus
   MENU
  }   }
  $r->print(<<"ENDSUBM");   $r->print(<<"ENDSUBM");
  <html>   <html>
Line 206  ENDSUBM Line 230  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','sort']);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register','sort','showOnlyHomework']);
           
 # ----------------------------------------------------- Force menu registration  # ----------------------------------------------------- Force menu registration
     my $addentries='';      my $addentries='';
     my $more_unload;      my $more_unload;
       my $body_only='';
     if ($ENV{'environment.remotenavmap'} eq 'on') {      if ($ENV{'environment.remotenavmap'} eq 'on') {
  $r->print('<script type="text/javascript">   $r->print('<script type="text/javascript">
                       function collapse() {                        function collapse() {
Line 219  ENDSUBM Line 244  ENDSUBM
                    </script>');                     </script>');
 # FIXME need to be smarter to only catch window close events  # FIXME need to be smarter to only catch window close events
 # $more_unload="collapse()"  # $more_unload="collapse()"
    $body_only=1;
     }      }
     if ($ENV{'form.register'}) {      if ($ENV{'form.register'}) {
  $addentries=' onLoad="'.&Apache::lonmenu::loadevents().   $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
Line 232  ENDSUBM Line 258  ENDSUBM
     # Header      # Header
     $r->print('</head>'.      $r->print('</head>'.
               &Apache::loncommon::bodytag('Navigate Course Contents','',                &Apache::loncommon::bodytag('Navigate Course Contents','',
                                     $addentries,'','',$ENV{'form.register'}));    $addentries,$body_only,'',
     $ENV{'form.register'}));
     $r->print('<script>window.focus();</script>'.      $r->print('<script>window.focus();</script>'.
       &Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT'));        &Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT'));
             
Line 286  ENDSUBM Line 313  ENDSUBM
     if ($ENV{'environment.remotenavmap'} eq 'on') {      if ($ENV{'environment.remotenavmap'} eq 'on') {
 #        $r->print("<a href='navmaps?collapseExternal'>" .  #        $r->print("<a href='navmaps?collapseExternal'>" .
         $r->print("<a href='javascript:collapse();void(0);'>" .          $r->print("<a href='javascript:collapse();void(0);'>" .
   &mt("Close separate navigation window").    &mt("Close navigation window").
   "</a>&nbsp;&nbsp;&nbsp;&nbsp;");    "</a>&nbsp;&nbsp;&nbsp;&nbsp;");
     }       } 
   
Line 335  ENDSUBM Line 362  ENDSUBM
   
     # Display only due homework.      # Display only due homework.
     my $showOnlyHomework = 0;      my $showOnlyHomework = 0;
     if ($ENV{QUERY_STRING} eq 'showOnlyHomework') {      if ($ENV{'form.showOnlyHomework'} eq "1") {
         $showOnlyHomework = 1;          $showOnlyHomework = 1;
         $suppressEmptySequences = 1;          $suppressEmptySequences = 1;
         $filterFunc = sub { my $res = shift;           $filterFunc = sub { my $res = shift; 
                             return $res->completable() || $res->is_map();                              return $res->completable() || $res->is_map();
                         };                          };
           $r->print("<a href='navmaps?sort=$ENV{'form.sort'}'>" .
     &mt("Show Everything")."</a>&nbsp;&nbsp;&nbsp;&nbsp;");
         $r->print("<p><font size='+2'>".&mt("Uncompleted Homework")."</font></p>");          $r->print("<p><font size='+2'>".&mt("Uncompleted Homework")."</font></p>");
         $ENV{'form.filter'} = '';          $ENV{'form.filter'} = '';
         $ENV{'form.condition'} = 1;          $ENV{'form.condition'} = 1;
  $resource_no_folder_link = 1;   $resource_no_folder_link = 1;
     } else {      } else {
         $r->print("<a href='navmaps?showOnlyHomework'>" .          $r->print("<a href='navmaps?sort=$ENV{'form.sort'}&showOnlyHomework=1'>" .
        &mt("Show Only Uncompleted Homework")."</a>&nbsp;&nbsp;&nbsp;&nbsp;");         &mt("Show Only Uncompleted Homework")."</a>&nbsp;&nbsp;&nbsp;&nbsp;");
     }      }
   
     $r->print("<form>      my %selected=($ENV{'form.sort'} => 'selected=on');
       my $sort_html=("<form>
                  <nobr>                   <nobr>
                     Sort by:                      <input type=\"hidden\" name=\"showOnlyHomework\" value=\"".$ENV{'form.showOnlyHomework'}."\" />
                       <input type=\"submit\" value=\"".&mt('Sort by:')."\" />
                     <select name=\"sort\">                      <select name=\"sort\">
                        <option value=\"\"></option>                         <option value=\"default\" $selected{'default'}>".&mt('Default')."</option>
                        <option value=\"title\">Title</option>                         <option value=\"title\"   $selected{'title'}  >".&mt('Title')."</option>
                        <option value=\"duedate\">Duedate</option>                         <option value=\"duedate\" $selected{'duedate'}>".&mt('Duedate')."</option>
                     </select>                      </select>
                     <input type=\"submit\" name=\"Sort\" />  
                  </nobr>                   </nobr>
                </form>");                 </form>");
     # renderer call      # renderer call
Line 370  ENDSUBM Line 400  ENDSUBM
                        'suppressEmptySequences' => $suppressEmptySequences,                         'suppressEmptySequences' => $suppressEmptySequences,
                        'filterFunc' => $filterFunc,                         'filterFunc' => $filterFunc,
        'resource_no_folder_link' => $resource_no_folder_link,         'resource_no_folder_link' => $resource_no_folder_link,
          'sort_html'=> $sort_html,
                        'r' => $r};                         'r' => $r};
     my $render = render($renderArgs);      my $render = render($renderArgs);
     $navmap->untieHashes();      $navmap->untieHashes();
Line 642  sub timeToHumanString { Line 673  sub timeToHumanString {
         }          }
   
         # Not this year, so show the year          # Not this year, so show the year
         my $timeStr = strftime("on %A, %b %e %G at %I:%M %P", localtime($time));          my $timeStr = strftime("on %A, %b %e %Y at %I:%M %P", localtime($time));
         $timeStr =~ s/12:00 am/00:00/;          $timeStr =~ s/12:00 am/00:00/;
         $timeStr =~ s/12:00 pm/noon/;          $timeStr =~ s/12:00 pm/noon/;
         return $timeStr;          return $timeStr;
Line 1381  sub render { Line 1412  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 1539  END Line 1567  END
     $result .= '<br />';      $result .= '<br />';
  }   }
     }      }
   
       if ($args->{'sort_html'}) { $result.=$args->{'sort_html'}; }
   
     $result .= "<br />\n";      $result .= "<br />\n";
     if ($r) {      if ($r) {
         $r->print($result);          $r->print($result);
Line 1614  END Line 1645  END
     my @resources;      my @resources;
     my $code='';# sub { !(shift->is_map();) };      my $code='';# sub { !(shift->is_map();) };
     if ($args->{'sort'} eq 'title') {      if ($args->{'sort'} eq 'title') {
  @resources=$navmap->retrieveResources(undef,          my $oldFilterFunc = $filterFunc;
        sub { !shift->is_map(); });   my $filterFunc= 
       sub {
    my ($res)=@_;
    if ($res->is_map()) { return 0;}
    return &$oldFilterFunc($res);
       };
    @resources=$navmap->retrieveResources(undef,$filterFunc);
  @resources= sort {lc($a->compTitle) cmp lc($b->compTitle)} @resources;   @resources= sort {lc($a->compTitle) cmp lc($b->compTitle)} @resources;
     } elsif ($args->{'sort'} eq 'duedate') {      } elsif ($args->{'sort'} eq 'duedate') {
  @resources=$navmap->retrieveResources(undef,   @resources=$navmap->retrieveResources(undef,
Line 1628  END Line 1665  END
  lc($a->compTitle) cmp lc($b->compTitle)   lc($a->compTitle) cmp lc($b->compTitle)
     }      }
  } @resources;   } @resources;
       } else {
    #unknow sort mechanism or default
    undef($args->{'sort'});
     }      }
   
   
     while (1) {      while (1) {
  if ($args->{'sort'}) {   if ($args->{'sort'}) {
     $curRes = shift(@resources);      $curRes = shift(@resources);
Line 2222  sub getById { Line 2263  sub getById {
 sub getBySymb {  sub getBySymb {
     my $self = shift;      my $self = shift;
     my $symb = shift;      my $symb = shift;
   
     my ($mapUrl, $id, $filename) = &Apache::lonnet::decode_symb($symb);      my ($mapUrl, $id, $filename) = &Apache::lonnet::decode_symb($symb);
     my $map = $self->getResourceByUrl($mapUrl);      my $map = $self->getResourceByUrl($mapUrl);
     return $self->getById($map->map_pc() . '.' . $id);      my $returnvalue = undef;
       if (ref($map)) {
           $returnvalue = $self->getById($map->map_pc() .'.'.$id);
       }
       return $returnvalue;
 }  }
   
 sub getByMapPc {  sub getByMapPc {
Line 2418  in the filter function. Line 2464  in the filter function.
   
 =cut  =cut
   
   
 sub getResourceByUrl {  sub getResourceByUrl {
     my $self = shift;      my $self = shift;
     my $resUrl = shift;      my $resUrl = shift;

Removed from v.1.275  
changed lines
  Added in v.1.280


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