Diff for /loncom/interface/lonindexer.pm between versions 1.39 and 1.42

version 1.39, 2002/03/19 19:55:52 version 1.42, 2002/05/31 21:50:30
Line 80  my $extrafield; # default extra table ce Line 80  my $extrafield; # default extra table ce
 my $fnum; # file counter  my $fnum; # file counter
 my $dnum; # directory counter  my $dnum; # directory counter
   
   # ----- Used to include or exclude files with certain extensions.
   my @Only = (); 
   my @Omit = ();
   
   
 # ----------------------------- Handling routine called via Apache and mod_perl  # ----------------------------- Handling routine called via Apache and mod_perl
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
Line 108  sub handler { Line 113  sub handler {
 # -------------------------------------- see if called from an interactive mode  # -------------------------------------- see if called from an interactive mode
     # Get the parameters from the query string      # Get the parameters from the query string
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
      ['catalogmode','launch','acts','mode','form','element']);       ['catalogmode','launch','acts','mode','form','element',
                 'only','omit']);
     #-------------------------------------------------------------------      #-------------------------------------------------------------------
     my $closebutton='';      my $closebutton='';
     my $groupimportbutton='';      my $groupimportbutton='';
Line 168  END Line 174  END
  &setvalues(\%hash,'form_mode'   ,\%ENV,'form.mode'   );   &setvalues(\%hash,'form_mode'   ,\%ENV,'form.mode'   );
  &setvalues(\%hash,'form_form'   ,\%ENV,'form.form'   );   &setvalues(\%hash,'form_form'   ,\%ENV,'form.form'   );
  &setvalues(\%hash,'form_element',\%ENV,'form.element');   &setvalues(\%hash,'form_element',\%ENV,'form.element');
    &setvalues(\%hash,'form_only'   ,\%ENV,'form.only'   );
    &setvalues(\%hash,'form_omit'   ,\%ENV,'form.omit'   );
   
           # Deal with 'omit' and 'only' 
           if (exists $ENV{'form.omit'}) {
               @Omit = split(',',$ENV{'form.omit'});
           }
           if (exists $ENV{'form.only'}) {
               @Only = split(',',$ENV{'form.only'});
           }
           
  my $mode = $ENV{'form.mode'};   my $mode = $ENV{'form.mode'};
  my ($form,$element);   my ($form,$element);
  if ($mode eq 'edit' || $mode eq 'parmset') {   if ($mode eq 'edit' || $mode eq 'parmset') {
Line 184  END Line 200  END
     # by default (ie. if $mode is undefined).  This is the easy      # by default (ie. if $mode is undefined).  This is the easy
     # way out.  Hopefully in the future I'll find a way to get       # way out.  Hopefully in the future I'll find a way to get 
     # the calls dealt with in a more comprehensive manner.      # the calls dealt with in a more comprehensive manner.
   
   #
   # There is now also mode "simple", which is for the simple version of the rat
   #
   #
     if (!defined($mode) || ($mode ne 'edit' && $mode ne 'parmset')) {      if (!defined($mode) || ($mode ne 'edit' && $mode ne 'parmset')) {
                   my $location = "/adm/groupsort?catalogmode=groupimport&";
                   $location .= "mode=".$mode."&";
                   $location .= "acts=";
  $catalogmodefunctions=<<"END";   $catalogmodefunctions=<<"END";
 function select_data(title,url) {  function select_data(title,url) {
     changeTitle(title);      changeTitle(title);
Line 192  function select_data(title,url) { Line 216  function select_data(title,url) {
     self.close();      self.close();
 }  }
 function select_group() {  function select_group() {
     window.location="/adm/groupsort?catalogmode=groupimport&acts="+document.forms.fileattr.acts.value;      window.location="$location"+document.forms.fileattr.acts.value;
 }  }
 function changeTitle(val) {  function changeTitle(val) {
     if (opener.inf) {      if (opener.inf) {
Line 210  function changeURL(val) { Line 234  function changeURL(val) {
 }  }
 END  END
             } elsif ($mode eq 'edit') { # we are in 'edit' mode              } elsif ($mode eq 'edit') { # we are in 'edit' mode
                   my $location = "/adm/groupsort?catalogmode=interactive&";
                   $location .= "form=$form&element=$element&mode=edit&acts=";
  $catalogmodefunctions=<<END;   $catalogmodefunctions=<<END;
 // mode = $mode  // mode = $mode
 function select_data(title,url) {  function select_data(title,url) {
Line 218  function select_data(title,url) { Line 244  function select_data(title,url) {
 }  }
   
 function select_group() {  function select_group() {
     window.location="/adm/groupsort?catalogmode=interactive&form=$form&element=$element&mode=edit&acts="+document.forms.fileattr.acts.value;      window.location="$location"+document.forms.fileattr.acts.value;
 }  }
   
 function changeURL(val) {  function changeURL(val) {
Line 231  function changeURL(val) { Line 257  function changeURL(val) {
   
 END  END
             } elsif ($mode eq 'parmset') {              } elsif ($mode eq 'parmset') {
                   my $location = "/adm/groupsort?catalogmode=interactive&";
                   $location .= "form=$form&element=$element&mode=parmset&acts=";
  $catalogmodefunctions=<<END;   $catalogmodefunctions=<<END;
 // mode = $mode  // mode = $mode
 function select_data(title,url) {  function select_data(title,url) {
Line 239  function select_data(title,url) { Line 267  function select_data(title,url) {
 }  }
   
 function select_group() {  function select_group() {
     window.location="/adm/groupsort?catalogmode=interactive&form=$form&element=$element&mode=parmset&acts="+document.forms.fileattr.acts.value;      window.location="$location"+document.forms.fileattr.acts.value;
 }  }
   
 function changeURL(val) {  function changeURL(val) {
Line 346  ENDHEADER Line 374  ENDHEADER
  }   }
   
 # ---------------------------------------------------------------- output title  # ---------------------------------------------------------------- output title
  $r->print('<h2><font color="#888888">The LearningOnline With CAPA '.   $r->print(
   '<h2><font color="#888888">The Learning<i>Online</i> Network with CAPA '.
   'Network Directory Browser</font></h2>'."\n");    'Network Directory Browser</font></h2>'."\n");
 # ---------------------------------- get state of file attributes to be showing  # ---------------------------------- get state of file attributes to be showing
  if ($ENV{'form.attrs'} ne "") {   if ($ENV{'form.attrs'} ne "") {
Line 389  END Line 418  END
   
 # ----------------- output starting row to the indexed file/directory hierarchy  # ----------------- output starting row to the indexed file/directory hierarchy
         my $titleclr="#ddffff";          my $titleclr="#ddffff";
         $r->print("<table border=0><tr><td bgcolor=#eeeeee>\n");  #        $r->print(&initdebug());
  $r->print("<table border=0><tr>\n");  #        $r->print(&writedebug("Omit:@Omit")) if (@Omit);
   #        $r->print(&writedebug("Only:@Only")) if (@Only);
           $r->print("<table width='100\%' border=0><tr><td bgcolor=#eeeeee>\n");
    $r->print("<table width='100\%' border=0><tr>\n");
  $r->print("<td $colspan bgcolor=$titleclr><b>Name</b></td>\n");   $r->print("<td $colspan bgcolor=$titleclr><b>Name</b></td>\n");
  $r->print("<td bgcolor=$titleclr align=right><b>Size (bytes) ".   $r->print("<td bgcolor=$titleclr align=right><b>Size (bytes) ".
   "</b></td>\n") if ($hash{'display_attrs_0'} == 1);    "</b></td>\n") if ($hash{'display_attrs_0'} == 1);
Line 543  sub get_list { Line 575  sub get_list {
     return @list=&match_ext($r,@list);      return @list=&match_ext($r,@list);
 }  }
   
   sub initdebug {
       return <<ENDJS;
   <script>
   var debugging = true;
   if (debugging) {
       var debuggingWindow = window.open('','Debug','width=400,height=300',true);
   } 
   
   function output(text) {
       if (debugging) {
           debuggingWindow.document.writeln(text);
       }
   }
   output("<html><head><title>Debugging Window</title></head><body><pre>");   
   </script>
   ENDJS
   }
   
   sub writedebug {
       my $text = shift;
       return "<script>output('$text');</script>";
   }
   
 # -------------------- filters out files based on extensions (returns an array)  # -------------------- filters out files based on extensions (returns an array)
 sub match_ext {  sub match_ext {
     my ($r,@packlist)=@_;      my ($r,@packlist)=@_;
Line 664  sub display_line { Line 719  sub display_line {
     if ($fnptr == 0 and $filecom[3] ne "") {      if ($fnptr == 0 and $filecom[3] ne "") {
  my @file_ext = split (/\./,$listname);   my @file_ext = split (/\./,$listname);
  my $curfext = $file_ext[-1];   my $curfext = $file_ext[-1];
           if (@Omit) {
               foreach (@Omit) { return OK if ($curfext eq $_); }
           }
           if (@Only) {
               my $skip = 1;
               foreach (@Only) { $skip = 0 if ($curfext eq $_); }
               return OK if ($skip > 0);
           }
  # Set the icon for the file   # Set the icon for the file
  my $iconname = "unknown.gif";   my $iconname = "unknown.gif";
  my $embstyle = &Apache::loncommon::fileembstyle($curfext);   my $embstyle = &Apache::loncommon::fileembstyle($curfext);
Line 680  sub display_line { Line 743  sub display_line {
     $title = &Apache::lonnet::metadata($filelink,'title')      $title = &Apache::lonnet::metadata($filelink,'title')
  if ($metafile == 1);   if ($metafile == 1);
     $title=$listname unless $title;      $title=$listname unless $title;
     my $titleesc=$title;      my $titleesc=HTML::Entities::encode($title);
     $titleesc=~s/\'/\\'/; #' (clean up this spare quote      $titleesc=~s/\'/\\'/; #' (clean up this spare quote)
             $r->print("<a href=\"javascript:select_data(\'",              $r->print("<a href=\"javascript:select_data(\'",
                       $titleesc,"','",$filelink,"')\">");                        $titleesc,"','",$filelink,"')\">");
     $r->print("<img src='",$iconpath,"select.gif' border='0' /></a>".      $r->print("<img src='",$iconpath,"select.gif' border='0' /></a>".
Line 693  sub display_line { Line 756  sub display_line {
     $title = &Apache::lonnet::metadata($filelink,'title')      $title = &Apache::lonnet::metadata($filelink,'title')
  if ($metafile == 1);   if ($metafile == 1);
     $title=$listname unless $title;      $title=$listname unless $title;
       my $titleesc=&HTML::Entities::encode($title);
     $r->print("<form name='form$fnum'>\n");      $r->print("<form name='form$fnum'>\n");
     $r->print("<input type='checkbox' name='filelink"."' ".      $r->print("<input type='checkbox' name='filelink"."' ".
       "value='$filelink' onClick='".        "value='$filelink' onClick='".
Line 702  sub display_line { Line 766  sub display_line {
     }      }
     $r->print(">\n");      $r->print(">\n");
     $r->print("<input type='hidden' name='title"."' ".      $r->print("<input type='hidden' name='title"."' ".
       "value='$title'>\n");        "value='$titleesc'>\n");
     $r->print("</form>\n");      $r->print("</form>\n");
     $r->print("</td><td valign='bottom' nowrap bgcolor=$fileclr>");      $r->print("</td><td valign='bottom' nowrap bgcolor=$fileclr>");
     $hash{"pre_${fnum}_link"}=$filelink;      $hash{"pre_${fnum}_link"}=$filelink;
     $hash{"pre_${fnum}_title"}=$title;      $hash{"pre_${fnum}_title"}=$titleesc;
      $fnum++;       $fnum++;
  }   }
   
Line 831  sub start_fresh_session { Line 895  sub start_fresh_session {
     delete $hash{'form_mode'};      delete $hash{'form_mode'};
     delete $hash{'form_form'};      delete $hash{'form_form'};
     delete $hash{'form_element'};      delete $hash{'form_element'};
       delete $hash{'form_omit'};
       delete $hash{'form_only'};
     foreach (keys %hash) {      foreach (keys %hash) {
  if ($_ =~ /^pre_/) {   if ($_ =~ /^pre_/) {
     delete $hash{$_};      delete $hash{$_};

Removed from v.1.39  
changed lines
  Added in v.1.42


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